require 'rubygems'
require 'hpricot'
require 'open-uri'

# Count hits on Golden Egg commands
 
# sum = 0
# 1.upto(12) do |page|
#   doc = Hpricot(open("http://yubnub.org/kernel/golden_eggs?page=#{page}"))
#   doc.search("//span[@class='hint']").each do |hint|
#     count = hint.inner_html.split(" ").first.to_i
#     puts count
#     sum += count
#   end
#   puts "cumulative: #{sum}"
# end
# puts "sum of golden egg hits: #{sum}"


# Count hits on all commands

sum = 0
1.upto(385) do |page|
  doc = Hpricot(open("http://yubnub.org/kernel/ls?page=#{page}"))
  doc.search("//span[@class='hint']").each do |hint|
    count = hint.inner_html.split(" ").first.to_i
    sum += count
  end
  puts "cumulative: #{sum}"
end
puts "sum of hits on all commands: #{sum}"